Skip to content

Conversation

@radarhere
Copy link
Member

Perhaps this is just me, but reading

if (!PyArg_ParseTuple(args, "O|(nnnn)", &op, &x0, &y0, &x1, &y1)) {

Pillow/src/encode.c

Lines 247 to 255 in e2b87a0

if (x0 == 0 && x1 == 0) {
state->xsize = im->xsize;
state->ysize = im->ysize;
} else {
state->xoff = x0;
state->yoff = y0;
state->xsize = x1 - x0;
state->ysize = y1 - y0;
}

my reaction is

Why if x0 and x1 are zero? If we're encoding an image with zero width, then use the full image size? That seems odd. Also, what if it is zero height?

The code has been like this since PIL. I suspect the intention was to handle

e.setimage(self.im)

where no extents are passed in, and say that in that scenario, the extents should default to the entire image.

I think it would simpler if we just explicitly passed that in from Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant